namespace ConsoleApp1;

public class Pointer
{
    static unsafe void t1()
    {
        int number = 10;

        // 声明一个指针并将其指向 number 变量的地址
        int* pointer = &number;

        // 输出变量的值和指针的值
        Console.WriteLine("Value of number: " + number);
        Console.WriteLine("Address of number: " + (long)pointer);

        // 通过指针修改变量的值
        *pointer = 20;

        // 再次输出变量的值，可以看到它已经被修改
        Console.WriteLine("New value of number: " + number);
    }
}

public struct Coords
{
    public int X;
    public int Y;
    public override string ToString() => $"({X}, {Y})";
}

public class PointerMemberAccessExample
{
    public static unsafe void t1()
    {
        Coords coords;
        Coords* p = &coords;
        p->X = 3;
        p->Y = 4;
        Console.WriteLine(p->ToString()); // output: (3, 4)
    }
}